package com.usian.cars.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.usian.cars.mapper.CarImagesMapper;
import com.usian.cars.service.ICarImagesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usian.common.Result;
import com.usian.common.ResultCodeEnum;
import com.usian.entity.CarImages;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2025-01-15
 */
@Service
public class CarImagesServiceImpl extends ServiceImpl<CarImagesMapper, CarImages> implements ICarImagesService {

    @Override
    public Result<String> getCarImagesByCarId(Integer carId) {
        LambdaQueryWrapper<CarImages> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(CarImages::getCarId,carId);
        CarImages carImages = getOne(wrapper);
        if (carImages == null){
            return Result.build("", ResultCodeEnum.CAR_NOT_EXIST);
        }
        return Result.build(carImages.getImageUrl(), ResultCodeEnum.SUCCESS);
    }
}
